#!/usr/bin/env bash

set -euo pipefail

export GO111MODULE=on
export GOFLAGS=-mod=vendor
export CGO_ENABLED=0
version=$(git describe --dirty --always)
LDFLAGS="-w -X github.com/coreos/butane/internal/version.Raw=$version"

eval $(go env)
if [ -z ${BIN_PATH+a} ]; then
	export BIN_PATH=${PWD}/bin/container/
fi

build_release() {
    export NAME="butane-${1}"
    echo "building ${NAME}"
    go build -o ${BIN_PATH}/${NAME} -ldflags "$LDFLAGS" internal/main.go
}

export GOOS=linux
export GOARCH=amd64
build_release x86_64-unknown-linux-gnu
